<?php
/**
 * Created by PhpStorm.
 * User: Bostin
 * Date: 2019-02-15
 * Time: 10:29
 */

namespace Bostin\Translator\Provider;


use Bostin\Translator\Sdk\Yeekit;
use Exception;

/**
 * Class YeekitProvider
 * @package Bostin\Translator\Provider
 */
class YeekitProvider extends AbstractProvider
{
    /**
     * @var
     */
    protected $client;

    /**
     * @return Yeekit
     */
    public function getClient()
    {
        if (is_null($this->client)) {
            $this->client = new Yeekit($this->config['app_kid'], $this->config['app_key'], $this->config);
        }
        return $this->client;
    }

    /**
     * @param string $sourceText
     * @param string $source
     * @param string $target
     * @return string|null
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function textTranslate(string $sourceText, string $source, string $target): ?string
    {
        return $this->getClient()->textTranslate($sourceText, $source, $target) ?? null;
    }

    /**
     * @param string $sourceText
     * @param string $source
     * @param string $target
     * @return string|null
     * @throws Exception
     */
    public function imageTranslate(string $sourceText, string $source, string $target): ?string
    {
        throw new Exception("not implement");
    }

    /**
     * @param string $audioFormat
     * @param int $seq
     * @param int $isEnd
     * @param string $sourceText
     * @param string $source
     * @param string $target
     * @return string|null
     * @throws Exception
     */
    public function speechTranslate(string $audioFormat, int $seq, int $isEnd, string $sourceText, string $source, string $target): ?string
    {
        throw new Exception("not implement");
    }
}